﻿
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using MaterialDesignThemes.Wpf;

namespace BankManage
{
    /// <summary>
    /// PaletteSelector.xaml 的交互逻辑
    /// </summary>
    public partial class PaletteSelector : UserControl
    {
        public PaletteSelector()
        {
            InitializeComponent();
        }


        //主题颜色的设置与更换
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var paletteHelper = new PaletteHelper();
            //Retrieve the app's existing theme
            ITheme theme = paletteHelper.GetTheme();

            Button item = e.Source as Button;

            switch (item.Tag)
            {
                case "弱紫罗兰红":
                    theme.SetPrimaryColor(Color.FromRgb(219, 112, 147));
                    break;
                case "紫兰色":
                    theme.SetPrimaryColor(Color.FromRgb(22, 97, 171));
                    break;
                case "中春绿色":
                    theme.SetPrimaryColor(Color.FromRgb(0, 250, 154));
                    break;
                case "春绿色":
                    theme.SetPrimaryColor(Color.FromRgb(0, 255, 127));
                    break;
                case "庚斯博罗灰":
                    theme.SetPrimaryColor(Color.FromRgb(220, 220, 220));
                    break;
                case "珊瑚":
                    theme.SetPrimaryColor(Color.FromRgb(255, 127, 80));
                    break;
                case "榴子红":
                    theme.SetPrimaryColor(Color.FromRgb(241, 144, 140));
                    break;
                case "暗青色":
                    theme.SetPrimaryColor(Color.FromRgb(0, 139, 139));
                    break;
                case "默认":
                    theme.SetPrimaryColor(Color.FromRgb(65, 105, 225));
                    break;

                default:
                    break;
            }
            MainSettings mainSettings = MainSettings.Default;
            MainSettings.Default.主题 = item.Tag.ToString();
            mainSettings.Save();
            paletteHelper.SetTheme(theme);
        }
    }
}
